_init() {
this.parent(0.0, _("Keyboard"));
+ this.connect('destroy', this._onDestroy.bind(this));
+
this._menuItems = {};
this._indicatorLabels = {};
this._sessionUpdated();
this._inputSourceManager = getInputSourceManager();
- this._inputSourceManager.connect('sources-changed', this._sourcesChanged.bind(this));
- this._inputSourceManager.connect('current-source-changed', this._currentSourceChanged.bind(this));
+ this._inputSourceManagerSourcesChangedId =
+ this._inputSourceManager.connect('sources-changed', this._sourcesChanged.bind(this));
+ this._inputSourceManagerCurrentSourceChangedId =
+ this._inputSourceManager.connect('current-source-changed', this._currentSourceChanged.bind(this));
this._inputSourceManager.reload();
},
+ _onDestroy() {
+ if (this._inputSourceManager) {
+ this._inputSourceManager.disconnect(this._inputSourceManagerSourcesChangedId);
+ this._inputSourceManager.disconnect(this._inputSourceManagerCurrentSourceChangedId);
+ this._inputSourceManager = null;
+ }
+ },
+
_sessionUpdated() {
// re-using "allowSettings" for the keyboard layout is a bit shady,
// but at least for now it is used as "allow popping up windows